<?php
include_once(SYSTEM.'/ValidationRule.php');

class Model
{
	private $Rules = array();

	public function AddRules($field, $rule)
	{
		$this->Rules[$field][] = $rule;
	}

	public function ValidateFields()
	{
		$errorMessage = array();
		
		foreach($this->Rules as $property => $rules)
		{			
			foreach($rules as $validationObject) 
			{													
				$message = $validationObject->Validate($this->$property);				
				if($message != 'OK')
				{					
					$errorMessage[$property] = $message;
					break;
				}
			}
		}
		
		return $errorMessage;
	}
}